package org.abc.fund.controller.funds;

import org.abc.fund.dto.FundTagRelationDTO;
import org.abc.fund.service.funds.FundTagRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/tag-relation")
public class FundTagRelationController {

    @Autowired
    private FundTagRelationService relationService;

    // 1. 添加标签关系
    @PostMapping("/add")
    public ResponseEntity<?> addRelation(@RequestParam String fundCode, @RequestParam Long tagId) {
        return relationService.addRelation(fundCode, tagId);
    }

    // 2. 查询基金的标签列表（DTO）
    @GetMapping("/{fundCode}")
    public List<FundTagRelationDTO> getTagsByFund(@PathVariable String fundCode) {
        return relationService.getTagsByFund(fundCode);
    }

    // 3. 删除基金-标签关系
    @DeleteMapping("/delete")
    public ResponseEntity<?> deleteRelation(@RequestParam String fundCode, @RequestParam Long tagId) {
        return relationService.deleteRelation(fundCode, tagId);
    }
}
